<template>
  <div class="app-container">
    <div v-if="device !== 'mobile'">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
        <el-form-item label="事件描述" prop="eventDesc">
          <el-input
            style="width: 150px"
            v-model="queryParams.eventDesc"
            placeholder="请输入事件描述"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="事件单号" prop="eventReceiptCode">
          <el-input
            style="width: 150px"
            v-model="queryParams.eventReceiptCode"
            placeholder="请输入事件单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="发版" prop="eventFbId">
          <el-select v-model="queryParams.eventFbId"
                     style="width: 170px"
                     filterable placeholder="请选择所属发版名称" @change="getChannelInfoList(true)">
            <el-option
              v-for="fbInfo in fbInfoList"
              :key="fbInfo.pkId"
              :label="fbInfo.fbName"
              :value="fbInfo.pkId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="应用系统" prop="eventChannelId">
          <el-select v-model="queryParams.eventChannelId"
                     style="width: 170px"
                     filterable placeholder="请选择所属应用系统名称">
            <el-option
              v-for="channelInfo in channelInfoListForQuery"
              :key="channelInfo.pkId"
              :label="channelInfo.channelName"
              :value="channelInfo.pkId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="状态" prop="eventState">
          <el-select v-model="queryParams.eventState"
                     style="width: 150px"
                     clearable filterable placeholder="请选择事件状态">
            <el-option
              v-for="data in dict.type.product_event_status"
              :key="data.value"
              :label="data.label"
              :value="data.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['yjcz:productEvent:add']"
          >新增</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="success"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleUpdate"
            v-hasPermi="['yjcz:productEvent:edit']"
          >修改</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['yjcz:productEvent:remove']"
          >删除</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['yjcz:productEvent:export']"
          >导出</el-button>
        </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>

      <el-table v-loading="loading" :data="productEventList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="生产事件标题" align="center" prop="eventTitle" />
        <el-table-column label="生产事件描述" align="center" prop="eventDesc" />
        <el-table-column label="生产事件单号" align="center" prop="eventReceiptCode" />
        <el-table-column label="生产事件发生时间" align="center" prop="eventHappenDt" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.eventHappenDt, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="发版名称" align="center" prop="fbInfo.fbName" />
        <el-table-column label="所属应用系统" align="center" prop="channelInfo.channelName" />
        <el-table-column label="适用应急场景" align="center" prop="scene.sceneName" />
        <el-table-column label="生产事件处置状态" align="center" prop="eventState">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.product_event_status" :value="scope.row.eventState"/>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleSearch(scope.row)"
            >查看</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['yjcz:productEvent:edit']"
            >修改</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-thumb"
              @click="handleEvent(scope.row)"
              v-hasPermi="['yjcz:productEvent:handle']"
            >处置</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit-outline"
              @click="handleAddDetail(scope.row)"
              v-hasPermi="['yjcz:productEvent:addDetail']"
            >补录</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['yjcz:productEvent:remove']"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />

      <!-- 添加或修改生产事件对话框 -->
      <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body :close-on-click-modal="false" :close-on-press-escape="false">
        <el-form ref="form" :model="form" :rules="rules" label-width="150px">
          <el-form-item label="生产事件标题" prop="eventTitle">
            <el-input v-model="form.eventTitle" placeholder="请输入生产事件标题" />
          </el-form-item>
          <el-form-item label="生产事件描述" prop="eventDesc">
            <el-input v-model="form.eventDesc" type="textarea" placeholder="请输入内容" />
          </el-form-item>
          <el-form-item label="生产事件单号" prop="eventReceiptCode">
            <el-input v-model="form.eventReceiptCode" placeholder="请输入生产事件单号" />
          </el-form-item>
          <el-form-item label="生产事件发生时间" prop="eventHappenDt">
            <el-date-picker clearable
                            v-model="form.eventHappenDt"
                            type="datetime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            placeholder="请选择生产事件发生时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="所属发版名称" prop="eventFbId">
            <el-select :disabled="form.eventState > 1" v-model="form.eventFbId" filterable placeholder="请选择所属发版名称" @change="getChannelInfoList(false)">
              <el-option
                v-for="fbInfo in fbInfoList"
                :key="fbInfo.pkId"
                :label="fbInfo.fbName"
                :value="fbInfo.pkId"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="所属应用系统名称" prop="eventChannelId">
            <el-select :disabled="form.eventState > 1" v-model="form.eventChannelId" filterable placeholder="请选择所属应用系统名称">
              <el-option
                v-for="channelInfo in channelInfoList"
                :key="channelInfo.pkId"
                :label="channelInfo.channelName"
                :value="channelInfo.pkId"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="所属应急场景" prop="eventSceneId">
            <el-select :disabled="form.eventState > 1" v-model="form.eventSceneId" filterable placeholder="请选择所属应急场景">
              <el-option
                v-for="scene in sceneList"
                :key="scene.pkId"
                :label="scene.sceneName"
                :value="scene.pkId"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </el-dialog>

      <!-- 处置生产事件对话框 -->
      <el-dialog :title="handleTimeLineTitle" :visible.sync="timeLineOpen" width="1200px" append-to-body :close-on-click-modal="false" :close-on-press-escape="false">
        <el-form label-width="150px">
          <el-form-item label="发版名称">
            {{handleTimeLineForm.fbName}}
          </el-form-item>
          <el-form-item label="系统名称">
            {{handleTimeLineForm.channelName}}
          </el-form-item>
          <el-form-item label="应急场景名称">
            {{handleTimeLineForm.sceneName}}
          </el-form-item>
          <el-form-item>
            <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="small"
              @click="handleExportTimeLine"
              v-hasPermi="['yjcz:productEvent:exportTimeLine']"
            >导出处置时间线</el-button>
          </el-form-item>
        </el-form>
        <el-table :data="handleTimeLineList">
          <el-table-column label="步骤" align="center" prop="nodeSeq" >
            <template slot-scope="scope">
              {{Number(scope.row.nodeSeq) + 1}}
            </template>
          </el-table-column>
          <el-table-column label="节点事项" align="center" prop="nodeContent" />
          <el-table-column label="节点时限要求" align="center" prop="nodeRequireMaxTime" />
          <el-table-column label="处置联系人" align="center" prop="nodeContactUser.nickName" />
          <el-table-column label="处置联系电话" align="center" prop="nodeContactUser.phonenumber" />
          <el-table-column label="节点处置备注" align="center" prop="nodeRemark" />
          <el-table-column label="处置状态" align="center" prop="handleState" >
            <template slot-scope="scope">
              <dict-tag :options="dict.type.node_handle_state" :value="scope.row.handleState"/>
            </template>
          </el-table-column>
          <el-table-column label="处置时间" align="center" prop="handleDt" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.handleDt, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="处置过程详细描述/备注" align="center" prop="handleDesc" />
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="markDownNode(scope.row)"
              >登记</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-dialog>

      <!-- 生产事件登记处置情况对话框 -->
      <el-dialog title="事项处置登记" :visible.sync="markOpen" width="500px" append-to-body :close-on-click-modal="false" :close-on-press-escape="false">
        <el-form ref="nodeForm" :model="nodeForm" :rules="nodeRules" label-width="150px">
          <el-form-item label="事项内容">
            {{ nodeForm.nodeContent }}
          </el-form-item>
          <el-form-item label="节点时限要求">
            {{ nodeForm.nodeRequireMaxTime }}
          </el-form-item>
          <el-form-item label="联系人">
            {{ nodeForm.contactNickName }}
          </el-form-item>
          <el-form-item label="联系电话">
            {{ nodeForm.contactPhonenumber }}
          </el-form-item>
          <el-form-item label="节点处置备注">
            {{ nodeForm.nodeRemark }}
          </el-form-item>
          <el-form-item label="处置状态" prop="handleState">
            <el-select v-model="nodeForm.handleState" filterable placeholder="请选择处置状态">
              <el-option
                v-for="states in dict.type.node_handle_state"
                :key="states.value"
                :label="states.label"
                :value="Number(states.value)"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="处置时间" prop="handleDt" v-if="nodeForm.handleState == 4">
            <el-date-picker clearable
                            v-model="nodeForm.handleDt"
                            type="datetime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            placeholder="请选择处置时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="处置过程详述/备注" prop="handleDesc">
            <el-input v-model="nodeForm.handleDesc" type="textarea" placeholder="请输入处置过程" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="sureMarkDown">确 定</el-button>
          <el-button @click="cancelMarkDown">取 消</el-button>
        </div>
      </el-dialog>


      <add-detail-dialog ref="addDetailDialog" @refershList="getList" />
      <event-search-dialog ref="eventSearchDialog" />
    </div>


    <div v-if="device === 'mobile'">
      <van-form>
        <van-field
          name="eventDesc"
          label="事件描述"
          placeholder="请填写事件描述"
          v-model="queryParams.eventDesc"
        />
        <van-field
          name="eventReceiptCode"
          label="事件单号"
          placeholder="请填写事项单号"
          v-model="queryParams.eventReceiptCode"
        />
        <fb-and-channel-select-picker
          ref="fbChannelPicker"
          :params="queryParams"
          fb-id-prop="eventFbId"
          channel-id-prop="eventChannelId"
        />
        <van-field-select-picker
          v-model="queryParams.eventState"
          label="状态"
          placeholder="点击选择事件状态"
          :columns="dict.type.product_event_status"
          :option="{label:'label',value:'value'}"
          :isSearch="true"
          @confirm="onConfirmEventState"
        />
        <div style="margin: 16px;">
          <!-- 居中 -->
          <van-row type="flex" justify="center">
            <van-col span="8">
              <van-button style="width: 100%" round type="info" native-type="submit" @click="handleQuery" icon="search">
                搜索
              </van-button>
            </van-col>
            <van-col span="2">
            </van-col>
            <van-col span="8">
              <van-button style="width: 100%" round type="default" @click="resetAndGetList" icon="replay">
                重置
              </van-button>
            </van-col>
          </van-row>
        </div>
      </van-form>

      <van-collapse v-model="mobilePluginsProp.activeNames">
        <van-swipe-cell v-for="item in productEventList">
          <van-collapse-item :title="item.eventDesc" :key="item.pkId">
            <van-cell-group>
              <van-cell :title="'系统：' + columnValueInObject(item.channelInfo, 'channelName')" />
              <van-cell :title="'发现方式：' + convertDictNameByValue(columnValueInObject(item.eventDetail, 'detailEventDiscoveryWay'), dict.type.event_discovery_way)" />
              <van-cell :title="'反馈行：' + columnValueInObject(item.eventDetail, 'detailEventFeedBank')" />
              <van-cell :title="'描述：' + item.eventDesc" />
              <van-cell :title="'原因：' + columnValueInObject(item.eventDetail, 'detailEventReason')" />
              <van-cell :title="'影响：' + columnValueInObject(item.eventDetail, 'detailEventEffective')" />
              <van-cell :title="'处理状态：' + convertDictNameByValue(columnValueInObject(item.eventDetail, 'detailEventSloveState'), dict.type.product_event_slove_state)" />
              <van-cell :title="'处理措施：' + columnValueInObject(item.eventDetail, 'detailEventTreatment')" />
              <van-cell :title="'CQ-id：' + columnValueInObject(item.eventDetail, 'detailLinkCq')" />
              <van-cell :title="'问题：' + columnValueInObject(item.eventDetail, 'detailPbmCode')" />
              <van-cell :title="'事件单：' + item.eventReceiptCode" />
              <van-cell :title="'对应发版CQ涉及部门：' + columnValueInObject(item.eventDetail, 'detailAboutDept')" />
              <van-cell :title="'表象系统所属部门：' + columnValueInObject(item.eventDetail, 'detailSurfaceDept')" />
            </van-cell-group>
          </van-collapse-item>
        </van-swipe-cell>
      </van-collapse>

      <van-pagination
        v-model="queryParams.pageNum"
        :total-items="total"
        :show-page-size="queryParams.pageSize"
        force-ellipses
        @change="getList"
      />
    </div>

  </div>
</template>

<script>
import {
  listProductEvent,
  getProductEvent,
  delProductEvent,
  addProductEvent,
  updateProductEvent,
  listFbInfo, listChannelInfo, listSceneInfo, doHandle, markDownLineNode, listAllScene
} from "@/api/yjcz/productEvent";
import {parseTime} from "@/utils/ruoyi";
import AddDetailDialog from "@/views/yjcz/productEvent/productEventDetail/addDetailDialog";
import EventSearchDialog from "@/views/yjcz/productEvent/eventSearchDialog";
import {mapState} from "vuex";
import FbAndChannelSelectPicker from "@/components/VantTools/FbAndChannelSelectPicker";
import VanFieldSelectPicker from "@/components/VantTools/VanFieldSelectPicker";

export default {
  name: "ProductEvent",
  components: {EventSearchDialog, AddDetailDialog, FbAndChannelSelectPicker, VanFieldSelectPicker},
  dicts: ['product_event_status', 'node_handle_state', 'event_discovery_way', 'product_event_slove_state'],
  computed: {
    ...mapState({
      device: state => state.app.device,
    })
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 生产事件表格数据
      productEventList: [],
      fbInfoList: [],
      channelInfoList: [],
      sceneList: [],
      channelInfoListForQuery: [],
      // 弹出层标题
      title: "",
      handleTimeLineTitle: '生产事件处置',
      handleTimeLineForm: {

      },
      // 是否显示弹出层
      open: false,
      timeLineOpen: false,
      markOpen: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        eventDesc: null,
        eventReceiptCode: null,
        eventFbId: null,
        eventChannelId: null,
        eventState: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        eventTitle: [
          { required: true, message: "生产事件标题不能为空", trigger: "blur" }
        ],
        eventDesc: [
          { required: true, message: "生产事件描述不能为空", trigger: "blur" }
        ],
        eventHappenDt: [
          { required: true, message: "生产事件发生时间不能为空", trigger: "blur" }
        ],
        eventFbId: [
          { required: true, message: "发版id不能为空", trigger: "change" }
        ],
        eventChannelId: [
          { required: true, message: "应用系统id不能为空", trigger: "change" }
        ],
      },
      handleTimeLineList: [],
      nodeForm: {},
      nodeRules: {
        handleDt: [
          { required: true, message: "处置时间不能为空", trigger: "blur" }
        ]
      },
      currProductEventId: '',
      mobilePluginsProp: {
        activeNames: []
      }
    };
  },
  created() {
    this.getFbInfoList()
    this.getList();
  },
  methods: {
    /** 查询生产事件列表 */
    getList() {
      this.loading = true;
      listProductEvent(this.queryParams).then(response => {
        this.productEventList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        pkId: null,
        eventTitle: null,
        eventDesc: null,
        eventReceiptCode: null,
        eventHappenDt: null,
        eventFbId: null,
        eventChannelId: null,
        eventSceneId: null,
        eventState: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
      this.getChannelInfoList(true)
    },
    resetAndGetList () {
      this.$refs.fbChannelPicker.resetSelect()
      Object.assign(this.queryParams, {
        eventDesc: null,
        eventReceiptCode: null,
        eventState: null,
        pageNum: 1
      })
      this.getList()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.pkId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.getChannelInfoList()
      this.getSceneInfoList()
      this.open = true;
      this.title = "添加生产事件";
    },
    handleSearch (row) {
      this.$refs.eventSearchDialog.show(row.pkId)
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const pkId = row.pkId || this.ids
      getProductEvent(pkId).then(response => {
        this.form = response.data;
        this.form.eventHappenDt = parseTime(this.form.eventHappenDt, '{y}-{m}-{d} {h}:{i}:{s}')
        this.getChannelInfoList()
        this.getSceneInfoList()
        this.open = true;
        this.title = "修改生产事件";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.pkId != null) {
            updateProductEvent(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addProductEvent(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const pkIds = row.pkId || this.ids;
      this.$modal.confirm('是否确认删除生产事件编号为"' + pkIds + '"的数据项？').then(function() {
        return delProductEvent(pkIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('yjcz/productEvent/export', {
        ...this.queryParams
      }, `productEvent_${new Date().getTime()}.xlsx`)
    },
    getFbInfoList() {
      listFbInfo().then(response => {
        if (response.code === 200) {
          this.fbInfoList = response.data
        }
      })
    },
    getChannelInfoList(isQuery) {
      let eventFbId
      if (isQuery) {
        eventFbId = this.queryParams.eventFbId
      } else {
        eventFbId = this.form.eventFbId
      }
      if (!eventFbId) {
        if (isQuery) {
          this.channelInfoListForQuery = []
          this.queryParams.eventChannelId = ''
        } else {
          this.channelInfoList = []
          this.form.eventChannelId = ''
        }
      } else {
        let eventChannelId
        if (isQuery) {
          eventChannelId = this.queryParams.eventChannelId
        } else {
          eventChannelId = this.form.eventChannelId
        }
        listChannelInfo(eventFbId).then(response => {
          if (response.code === 200) {
            let channelList = response.data
            if (isQuery) {
              this.channelInfoListForQuery = channelList
            } else {
              this.channelInfoList = channelList
            }
            let exists = (channelList.findIndex(d => d.pkId == eventChannelId) > -1)
            if (!exists) {
              if (isQuery) {
                this.queryParams.eventChannelId = ''
              } else {
                this.form.eventChannelId = ''
              }
            }
          }
        })
      }
    },
    getSceneInfoList () {
      listAllScene().then(response => {
        if (response.code === 200) {
          this.sceneList = response.data
        }
      })
    },
    handleEvent (row) {
      let eventSceneId = row.eventSceneId
      if (!eventSceneId) {
        this.$modal.msgWarning("请先选择该生产事件对应的处置场景");
        return
      }
      this.handleTimeLineForm = {
        fbName: row.fbInfo.fbName,
        channelName: row.channelInfo.channelName,
        sceneName: row.scene.sceneName
      }
      this.currProductEventId = row.pkId
      doHandle(row).then(response => {
        if (response.code === 200) {
          this.handleTimeLineList = response.data
          this.timeLineOpen = true
        } else {
          this.$modal.msgError(response.msg);
        }
      })
    },
    handleExportTimeLine () {
      this.download('yjcz/productEvent/exportTimeLine', {pkId: this.currProductEventId}, `处置时间线_${new Date().getTime()}.xlsx`)
    },
    handleAddDetail (row) {
      this.$refs.addDetailDialog.show(row.pkId)
    },
    markDownNode (row) {
      this.nodeForm = JSON.parse(JSON.stringify(row))
      let contactUser
      let hasContactUser = this.nodeForm.hasOwnProperty('nodeContactUser') && null != (contactUser = this.nodeForm.nodeContactUser)
      Object.assign(this.nodeForm, {
        nodeContent: this.nodeForm.nodeContent,
        nodeRequireMaxTime: this.nodeForm.nodeRequireMaxTime,
        contactNickName: hasContactUser ? contactUser.nickName : '无',
        contactPhonenumber: hasContactUser ? contactUser.phonenumber : '无'
      })
      this.markOpen = true
    },
    sureMarkDown () {
      this.$refs["nodeForm"].validate(valid => {
        if (valid) {
          let handleState = this.nodeForm.handleState
          if (handleState != 4) {
            this.nodeForm.handleDt = ''
          }
          markDownLineNode(this.nodeForm).then(response => {
            if (response.code === 200) {
              let idx = this.handleTimeLineList.findIndex(r => r.pkId == this.nodeForm.pkId)
              this.handleTimeLineList[idx] = this.nodeForm
              this.handleTimeLineList = JSON.parse(JSON.stringify(this.handleTimeLineList))
              this.$modal.msgSuccess('登记成功');
              this.getList()
              this.markOpen = false
            } else {
              this.$modal.msgError(response.msg);
            }
          })
        }
      })
    },
    cancelMarkDown () {
      this.markOpen = false
    },
    onConfirmEventState (value) {
      this.queryParams.eventState = value.value
    },
    mobileListNullCell (value) {
      return value ? value : '无'
    },
    columnValueInObject (obj, colName) {
      if (null == obj) {
        return '无'
      }
      if (null == obj[colName]) {
        return '无'
      }
      return obj[colName]
    },
    convertDictNameByValue (value, dictList) {
      if (null == value || '无' == value || null == dictList || 0 == dictList.length) {
        return '无'
      }
      let matchedList = dictList.filter(item => item.value == value)
      if (null == matchedList || 0 == matchedList.length) {
        return '无'
      }
      return matchedList[0].label
    }
  }
};
</script>
